package com.woldier.task.demo01;

import com.woldier.aop.demo01.TaskAop;
import com.woldier.aop.demo02.Task02Anno;
import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.framework.AopContext;
import org.springframework.stereotype.Component;

@Slf4j
@Component //交给spring
public class TaskImpl implements ITask{
    @Override
    @TaskAop //注解位joinPoint
    public void doing() {
      log.info("hello aop");
      /*自己调用,doing2无法被aop*/
      this.doing2();
      /*代理对象调用,可以被aop*/
      getThis().doing2();
    }



    @Override
    @TaskAop //注解位joinPoint
    public void doing2() {
        log.info("hello aop2 ");
    }

    @Override
    @Task02Anno
    public String doing3(String s) {
        log.info("=================in fun doing3=================="
        );
        return s;
    }


    /**
     * 获取被代理的对象
     */
    TaskImpl getThis(){
        return (TaskImpl) AopContext.currentProxy();
    }
}
